//
//  AlbumInfo.m
//  20-Homework
//
//  Created by dllo on 16/8/10.
//  Copyright © 2016年 ZHW. All rights reserved.
//

#import "AlbumInfo.h"
#import "Actor.h"
#import "Directors.h"
#import "Categories.h"
#import "VoiceActors.h"

@implementation AlbumInfo
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if ([key isEqualToString:@"actors"]) {
        NSMutableArray *actorArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            Actor *actor = [Actor modelWithDictionary:dic];
            [actorArray addObject:actor];
        }
        _actors = actorArray;
    } else if ([key isEqualToString:@"directors"]) {
        NSMutableArray *directorsArr = [NSMutableArray array];
        for (NSDictionary *dic in _directors) {
            Directors *director = [Directors modelWithDictionary:dic];
            [directorsArr addObject:director];
        }
        _directors = directorsArr;
    } else if ([key isEqualToString:@"categories"]) {
        NSMutableArray *cateArray = [NSMutableArray array];
        for (NSDictionary *dic in _categories) {
            Categories *cate = [Categories modelWithDictionary:dic];
            [cateArray addObject:cate];
        }
        _categories = cateArray;
    } else if ([key isEqualToString:@"voiceActors"]) {
        NSMutableArray *voiceArray = [NSMutableArray array];
        for (NSDictionary *dic in _voiceActors) {
            VoiceActors *voiceActor = [VoiceActors modelWithDictionary:dic];
            [voiceArray addObject:voiceActor];
        }
        _voiceActors = voiceArray;
    }
}

- (NSString *)description {
    return [NSString stringWithFormat:@"%@--%@--", _totalNum, _playtimes];
}
@end
